{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "50f3903e-743d-4a06-8548-6ff7f5289927",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "418"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import requests\n",
    "\n",
    "response = requests.get('https://www.douban.com/')\n",
    "\n",
    "response.status_code"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2cb29b98-2125-4eeb-81b5-cac042d24732",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "045adfd7-8e51-4887-83a3-4287067c254d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "''"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "response.text"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "80fd91d8-b684-4921-b9ea-c9898a0bc24a",
   "metadata": {},
   "outputs": [],
   "source": [
    "response = requests.get('https://www.douban.com/search',params={'q': 'cat', })"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "f360251c-fcf0-484d-a80c-291fbd8cf81a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "b''\n"
     ]
    }
   ],
   "source": [
    "print(response.content)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "4d283564-31b2-40f0-9d6d-ae5fbac4e00e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    }
   ],
   "source": [
    "print(response.text)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "1e466011-c79b-46e8-87e0-2a084f512298",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<!DOCTYPE html>\n",
      "<!--STATUS OK--><html> <head><meta http-equiv=content-type content=text/html;charset=utf-8><meta http-equiv=X-UA-Compatible content=IE=Edge><meta content=always name=referrer><link rel=stylesheet type=text/css href=https://ss1.bdstatic.com/5eN1bjq8AAUYm2zgoY3K/r/www/cache/bdorz/baidu.min.css><title>ç¾åº¦ä¸ä¸ï¼ä½ å°±ç¥é</title></head> <body link=#0000cc> <div id=wrapper> <div id=head> <div class=head_wrapper> <div class=s_form> <div class=s_form_wrapper> <div id=lg> <img hidefocus=true src=//www.baidu.com/img/bd_logo1.png width=270 height=129> </div> <form id=form name=f action=//www.baidu.com/s class=fm> <input type=hidden name=bdorz_come value=1> <input type=hidden name=ie value=utf-8> <input type=hidden name=f value=8> <input type=hidden name=rsv_bp value=1> <input type=hidden name=rsv_idx value=1> <input type=hidden name=tn value=baidu><span class=\"bg s_ipt_wr\"><input id=kw name=wd class=s_ipt value maxlength=255 autocomplete=off autofocus=autofocus></span><span class=\"bg s_btn_wr\"><input type=submit id=su value=ç¾åº¦ä¸ä¸ class=\"bg s_btn\" autofocus></span> </form> </div> </div> <div id=u1> <a href=http://news.baidu.com name=tj_trnews class=mnav>æ°é»</a> <a href=https://www.hao123.com name=tj_trhao123 class=mnav>hao123</a> <a href=http://map.baidu.com name=tj_trmap class=mnav>å°å¾</a> <a href=http://v.baidu.com name=tj_trvideo class=mnav>è§é¢</a> <a href=http://tieba.baidu.com name=tj_trtieba class=mnav>è´´å§</a> <noscript> <a href=http://www.baidu.com/bdorz/login.gif?login&amp;tpl=mn&amp;u=http%3A%2F%2Fwww.baidu.com%2f%3fbdorz_come%3d1 name=tj_login class=lb>ç»å½</a> </noscript> <script>document.write('<a href=\"http://www.baidu.com/bdorz/login.gif?login&tpl=mn&u='+ encodeURIComponent(window.location.href+ (window.location.search === \"\" ? \"?\" : \"&\")+ \"bdorz_come=1\")+ '\" name=\"tj_login\" class=\"lb\">ç»å½</a>');\n",
      "                </script> <a href=//www.baidu.com/more/ name=tj_briicon class=bri style=\"display: block;\">æ´å¤äº§å</a> </div> </div> </div> <div id=ftCon> <div id=ftConw> <p id=lh> <a href=http://home.baidu.com>å",
      "³äºç¾åº¦</a> <a href=http://ir.baidu.com>About Baidu</a> </p> <p id=cp>&copy;2017&nbsp;Baidu&nbsp;<a href=http://www.baidu.com/duty/>ä½¿ç¨ç¾åº¦åå¿",
      "è¯»</a>&nbsp; <a href=http://jianyi.baidu.com/ class=cp-feedback>æè§åé¦</a>&nbsp;äº¬ICPè¯030173å·&nbsp; <img src=//www.baidu.com/img/gs.gif> </p> </div> </div> </div> </body> </html>\n",
      "\n"
     ]
    }
   ],
   "source": [
    "response = requests.get('https://www.baidu.com')\n",
    "\n",
    "print(response.text)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "074b3a57-3ca1-43be-a162-b0cd182c19b2",
   "metadata": {},
   "outputs": [],
   "source": [
    " r = requests.get('https://www.douban.com/', headers={'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit'})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "7965d521-e4eb-4ce2-b49b-d5948244f819",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "\n",
      "<!DOCTYPE html>\n",
      "<html itemscope itemtype=\"http://schema.org/WebPage\" class=\"ua-mobile \">\n",
      "  <head>\n",
      "      <meta charset=\"UTF-8\">\n",
      "      <title>豆瓣(手机版)</title>\n",
      "      <meta name='360_ssp_verify' content='ee7f73d3af2299c1c780fe7f3a657c51' />\n",
      "      <meta name=\"google-site-verification\" content=\"ok0wCgT20tBBgo9_zat2iAcimtN4Ftf5ccsh092Xeyw\" />\n",
      "      <meta name=\"viewport\" content=\"width=device-width, height=device-height, user-scalable=no, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0\">\n",
      "      <meta name=\"format-detection\" content=\"telephone=no\">\n",
      "      <meta name=\"description\" content=\"读书、看电影、涨知识、学穿搭...，加入兴趣小组，获得达人们的高质量生活经验，找到有相同爱好的小伙伴。\">\n",
      "      <meta name=\"keywords\" content=\"豆瓣,手机豆瓣,豆瓣手机版,豆瓣电影,豆瓣读书,豆瓣同城\">\n",
      "      <link rel=\"canonical\" href=\"\n",
      "https://m.douban.com/\">\n",
      "      <link href=\"https://img1.doubanio.com/f/talion/a857c356b742b859698d063cbeb65bcbf1362c80/css/card/base.css\" rel=\"stylesheet\">\n",
      "      \n",
      "<script>\n",
      "  var saveKey = '_t_splash'\n",
      "  var day = 3\n",
      "  if (Date.now() - window.localStorage.getItem(saveKey) < 1000 * 60 * 60 * 24 * day) {\n",
      "    window.location.replace('/home_guide')\n",
      "  } else {\n",
      "    window.addEventListener('click', function(e) {\n",
      "      if (e.target.id === 'home_guide') {\n",
      "        window.localStorage.setItem(saveKey, Date.now())\n",
      "      }\n",
      "    })\n",
      "  }\n",
      "</script>\n",
      "\n",
      "      <link rel=\"stylesheet\" href=\"https://img1.doubanio.com/misc/mixed_static/4f3062503e5a7c84.css\">\n",
      "      <link rel=\"shortcut  icon\" href=\"https://img1.doubanio.com/f/talion/2f3c0bc0f35b031d4535fd993ae3936f4e40e6c8/pics/icon/dou32.png\" type=\"image/x-icon\" />\n",
      "      <link rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"https://img1.doubanio.com/f/talion/c970bb0d720963a7392f7dd6c77068bb9925caaf/pics/icon/dou16.png\">\n",
      "      <link rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"https://img1.doubanio.com/f/talion/2f3c0bc0f35b031d4535fd993ae3936f4e40e6c8/pics/icon/dou32.png\">\n",
      "      <link rel=\"icon\" type=\"image/png\" sizes=\"48x48\" href=\"https://img1.doubanio.com/f/talion/10a4a913a5715f628e4b598f7f9f2c18621bdcb3/pics/icon/dou48.png\">\n",
      "      <!-- iOS touch icon -->\n",
      "      <link rel=\"apple-touch-icon-precomposed\" href=\"https://img1.doubanio.com/f/talion/997f2018d82979da970030a5eb84c77f0123ae5f/pics/icon/m_logo_76.png\">\n",
      "      <link rel=\"apple-touch-icon-precomposed\" sizes=\"76x76\" href=\"https://img1.doubanio.com/f/talion/997f2018d82979da970030a5eb84c77f0123ae5f/pics/icon/m_logo_76.png\">\n",
      "      <link rel=\"apple-touch-icon-precomposed\" sizes=\"120x120\" href=\"https://img1.doubanio.com/f/talion/18932a3e71a60ed7150ca2ca7ebf21ddadd7092e/pics/icon/m_logo_120.png\">\n",
      "      <link rel=\"apple-touch-icon-precomposed\" sizes=\"152x152\" href=\"https://img1.doubanio.com/f/talion/b99497ff8538c54b9ba6f40867da932396ab2562/pics/icon/m_logo_152.png\">\n",
      "      <link rel=\"apple-touch-icon-precomposed\" sizes=\"167x167\" href=\"https://img1.doubanio.com/f/talion/0c233ada957a95e632f81607e30230d16e8293e8/pics/icon/m_logo_167.png\">\n",
      "      <link rel=\"apple-touch-icon-precomposed\" sizes=\"180x180\" href=\"https://img1.doubanio.com/f/talion/8e7b9cbd097c02972c4191aa03fdb084524505c4/pics/icon/m_logo_180.png\">\n",
      "      <link rel=\"apple-touch-icon-precomposed\" sizes=\"200x200\" href=\"https://img1.doubanio.com/f/talion/7c6364aadf368dc0210173c940cfd0f64ceddc66/pics/icon/m_logo_200.png\">\n",
      "      <!-- For Android -->\n",
      "      <link rel=\"icon\" sizes=\"128x128\" href=\"https://img1.doubanio.com/f/talion/b99497ff8538c54b9ba6f40867da932396ab2562/pics/icon/m_logo_152.png\">\n",
      "      <link rel=\"icon\" sizes=\"192x192\" href=\"https://img1.doubanio.com/f/talion/7c6364aadf368dc0210173c940cfd0f64ceddc66/pics/icon/m_logo_200.png\">\n",
      "      <!-- For Web App Manifest -->\n",
      "      <link type=\"application/opensearchdescription+xml\" rel=\"search\" href=\"/opensearch\"/>\n",
      "          <!-- hm baidu -->\n",
      "          <script type=\"text/javascript\">\n",
      "          var _hmt = _hmt || [];\n",
      "          (function() {\n",
      "            var hm = document.createElement(\"script\");\n",
      "            hm.src = \"https://hm.baidu.com/hm.js?6d4a8cfea88fa457c3127e14fb5fabc2\";\n",
      "            var s = document.getElementsByTagName(\"script\")[0];\n",
      "            s.parentNode.insertBefore(hm, s);\n",
      "          })();\n",
      "          _hmt.logTruncate = function(type) {\n",
      "              _hmt.push(['_trackEvent', 'article', 'truncate', type, 1]);\n",
      "          }\n",
      "          </script>\n",
      "  </head>\n",
      "  <body ontouchstart=\"\">\n",
      "    \n",
      "    <div class=\"page\">\n",
      "        \n",
      "  \n",
      "  \n",
      "  <div class=\"splash\">\n",
      "    <div class=\"splash-content\">\n",
      "      <div class=\"splash-pic\">\n",
      "        <img src=\"https://img1.doubanio.com/f/talion/706ae8511b66f390ae0427daf85df7ddd93ab1b9/pics/card/splash/splash_bg.jpg\" />\n",
      "      </div>\n",
      "    </div>\n",
      "    <div class=\"splash-bottom\">\n",
      "      <div class=\"splash-text\">\n",
      "        <p class=\"splash-text-main\">来豆瓣，记录你的书影音生活</p>\n",
      "        <!-- <p>更多书影音讨论在豆瓣App</p> -->\n",
      "      </div>\n",
      "      <a class=\"splash-btn\" href=\"https://m.douban.com/to_app?copy_open=1&url=/recommend_feed&source=splash\">下载App</a>\n",
      "      <a class=\"splash-link\" id=\"home_guide\" href=\"/home_guide\">进入网页版 &gt;</a>\n",
      "    </div>\n",
      "  </div>\n",
      "\n",
      "    </div>\n",
      "    <script src=\"https://img1.doubanio.com/f/talion/ee8e0c54293aefb5709ececbdf082f8091ad5e49/js/card/zepto.min.js\"></script>\n",
      "    \n",
      "  </body>\n",
      "</html>\n",
      "\n",
      "\n",
      "\n",
      "\n",
      "\n",
      "\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "print(r.text)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e68903a8-d879-4d37-adfa-c95e96dba3ca",
   "metadata": {},
   "outputs": [],
   "source": [
    "loginResponse = requests.post('https://accounts.douban.com/login')"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.21"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
